from os.path import split

from sympy.plotting.intervalmath import interval


class Lw100QAUtil:

    @classmethod
    def convert_to_register_address(cls, parameter_number: str) -> int:
        """
        LW100_QA全功能servo motor driver
        参数编号转换成寄存器地址
        eg：H00.00
        :param parameter_number:
        :return:
        """
        # 获取十六进制数字
        left_number = parameter_number.split(".")
        left_number_str = left_number[0].replace("H", "")
        right_number_str = left_number[1]
        right_number_int = int(right_number_str)

        # 整数转两位十六进制数
        right_hex_str = cls.int_to_hex_2digits(right_number_int)

        hex_str = left_number_str + right_hex_str

        hex_int = int(hex_str, 16)
        # print(f"right_hex_str: {right_hex_str}, hex_str: {hex_str}, hex_int: {hex_int}")
        return hex_int

    @staticmethod
    def int_to_hex_2digits(number: int):
        return f'{number:02x}'


if __name__ == "__main__":
    Lw100QAUtil.convert_to_register_address("H0D.55")
